<?php

namespace App\Http\Resources\Train\Transfer;

use App\Trip\Train\TrainType;
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
use JsonSerializable;

class TransferInfoResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param Request $request
     * @return array|Arrayable|JsonSerializable
     */
    public function toArray($request)
    {
        $res         = parent::toArray($request);
        $type_name   = TrainType::getTrainTypeName($res['train_code']);
        $res['type'] = [
            "name"    => $type_name,
            "name_uy" => TrainType::getTrainTypeNameTranslation($type_name, 'uy'),
        ];
        return $res;
    }
}
